package com.itheima.job;

import java.util.ArrayList;
import java.util.Iterator;

public class Test02 {
    public static void main(String[] args) {
        ArrayList<Integer> arrayList = new ArrayList<>();
        arrayList.add(1);
        arrayList.add(2);
        arrayList.add(3);
        arrayList.add(4);
        int i = listTest(arrayList, 5);
        System.out.println(i);
        int i1 = listTest(arrayList, 3);
        System.out.println(i1);

    }
    public static int  listTest(ArrayList<Integer> al, Integer s){
        for (int i = 0; i < al.size(); i++) {
            if (al.get(i).equals(s)){
                return i;
            }
        }
        return -1;
    }
}
